//
//  ViewController.m
//  UI_Day02_homework
//
//  Created by aaaaaa on 16/6/4.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "CustumUILable.h"
#import "CustomUITextField.h"
#import "Animation.h"

@interface ViewController ()<UITextFieldDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self homework1];
    [self homework2];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)homework1{
//    UILabel *userNameLable = [[UILabel alloc] initWithFrame:CGRectMake(50, 50, 80, 30)];
////    userNameLable.backgroundColor = [UIColor yellowColor];
//    userNameLable.text = @"用户名";
//    [self.view addSubview:userNameLable];
//    [userNameLable release];
//    
//    UITextField *userNameText = [[UITextField alloc] initWithFrame:CGRectMake(180, 50, 150, 30)];
//    userNameText.layer.borderColor = [UIColor grayColor].CGColor;
//    userNameText.layer.borderWidth = 1.0f;
//    userNameText.layer.masksToBounds = YES;
//    userNameText.layer.cornerRadius = 5.0;
//    userNameText.placeholder = @" 请输入用户名";
//    [self.view addSubview:userNameText];
//    [userNameText release];
    
    
    CustumUILable *userNameLable = [CustumUILable custumUILableWithFrame:CGRectMake(50 + 32, 50, 80, 30) withText:@"用户名"];
    [self.view addSubview:userNameLable];
    
    CustomUITextField *userNameTextField = [CustomUITextField customUITextFieldWithFrame:CGRectMake(150 + 32, 50, 150, 30) withPlaceholder:@"请输入用户名"];
    userNameTextField.tag = 1;
    [self.view addSubview:userNameTextField];
    
    
    CustumUILable *passWordLable = [CustumUILable custumUILableWithFrame:CGRectMake(50 + 32, 120, 80, 30) withText:@"密码"];
    [self.view addSubview:passWordLable];
    
    CustomUITextField *passWordTextField = [CustomUITextField customUITextFieldWithFrame:CGRectMake(150 + 32, 120, 150, 30) withPlaceholder:@"请输入密码"];
    passWordTextField.secureTextEntry = YES;
    passWordTextField.tag = 2;
    [self.view addSubview:passWordTextField];
    
    
    CustumUILable *rePassWordLable = [CustumUILable custumUILableWithFrame:CGRectMake(50 + 32, 190, 80, 30) withText:@"确认密码"];
    [self.view addSubview:rePassWordLable];
    
    CustomUITextField *rePassWordTextField = [CustomUITextField customUITextFieldWithFrame:CGRectMake(150 + 32, 190, 150, 30) withPlaceholder:@"再次输入密码"];
    rePassWordTextField.secureTextEntry = YES;
    rePassWordTextField.tag = 3;
    [self.view addSubview:rePassWordTextField];
    
    
    CustumUILable *phoneLable = [CustumUILable custumUILableWithFrame:CGRectMake(50 + 32, 260, 80, 30) withText:@"手机号"];
    [self.view addSubview:phoneLable];
    
    CustomUITextField *phoneTextField = [CustomUITextField customUITextFieldWithFrame:CGRectMake(150 + 32, 260, 150, 30) withPlaceholder:@"请输入联系方式"];
    phoneTextField.keyboardType = UIKeyboardTypeNumberPad;
    phoneTextField.tag = 4;
    [self.view addSubview:phoneTextField];
    
    CustumUILable *emailLable =[CustumUILable custumUILableWithFrame:CGRectMake(50 + 32, 330, 80, 30) withText:@"邮箱"];
    [self.view addSubview:emailLable];
    
    CustomUITextField *emailTextField = [CustomUITextField customUITextFieldWithFrame:CGRectMake(150 + 32, 330, 150, 30) withPlaceholder:@"请输入邮箱"];
    emailTextField.tag = 5;
    [self.view addSubview:emailTextField];
    
    UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
    loginButton.frame = CGRectMake(50 + 32 + 50, 400, 50, 30);
    [loginButton setTitle:@"注册" forState:UIControlStateNormal];
    [loginButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [self.view addSubview:loginButton];
    [loginButton addTarget:self action:@selector(recoveryKeyboaed:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeSystem];
    cancelButton.frame = CGRectMake(190 + 32, 400, 50, 30);
    [cancelButton setTitle:@"取消" forState:UIControlStateNormal];
    [cancelButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [cancelButton addTarget:self action:@selector(recoveryKeyboaed:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:cancelButton];
    
}
//点击按钮时回收键盘
- (void)recoveryKeyboaed:(UIButton *)button{
   // CustomUITextField *custom = (CustomUITextField *)[]
    UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
    UITextField *firstResponder = (UITextField *)[keyWindow performSelector:@selector(firstResponder)];
    [firstResponder resignFirstResponder];
}

- (void)homework2{
    UIImage *backGroundImage = [UIImage imageNamed:@"BackGround.png"];
    UIImageView *backGroundImageView = [[UIImageView alloc] initWithImage:backGroundImage];
    backGroundImageView.frame = CGRectMake(0, 0, 414, 736);
    [self.view addSubview:backGroundImageView];
    [backGroundImageView release];
    
    Animation *flower = [Animation animationWithImageName:@"flower" withImageFormat:@"tiff" withStartCount:1 withImageCount:18 withImageFrame:CGRectMake(70, 100, 73, 74)];
    [backGroundImageView addSubview:flower];
    
    Animation *gua = [Animation animationWithImageName:@"gua" withImageFormat:@"tiff" withStartCount:1 withImageCount:16 withImageFrame:CGRectMake(250, 80, 106, 98)];
    [backGroundImageView addSubview:gua];
    
    Animation *plants = [Animation animationWithImageName:@"plants" withImageFormat:@"tiff" withStartCount:1 withImageCount:9 withImageFrame:CGRectMake(60, 340, 106, 107)];
    [backGroundImageView addSubview:plants];
    
    Animation *zombie = [Animation animationWithImageName:@"Zombie" withImageFormat:@"tiff" withStartCount:0 withImageCount:22 withImageFrame:CGRectMake(200, 320, 164, 144)];
    [backGroundImageView addSubview:zombie];
}


































@end
